package com.advanced.date;

import java.util.*;

import com.advanced.homeworkCompany.Employee;

public class ListPare {

	public static void main(String[] args) {
		List al = new ArrayList();
		List ll = new LinkedList();
		// ArrayList计算时间:16
		long start1 = System.currentTimeMillis();
		for (int i = 0; i < 100000; i++) {
			al.add(new Employee("老王"));
		}
		long end1 = System.currentTimeMillis();
		System.out.println("ArrayList加入10万个对象时间：" + (end1 - start1));
		// LinkedList计算时间:11
		long start2 = System.currentTimeMillis();
		for (int i = 0; i < 100000; i++) {
			ll.add(new Employee("老王"));
		}
		long end2 = System.currentTimeMillis();
		System.out.println("LinkedList加入10万个对象时间：" + (end2 - start2));
		// ArrayList随机删除100个:78
		long start3 = System.currentTimeMillis();
		for (int i = 0; i < 100; i++) {
			al.remove(Math.random() * 100000);
		}
		long end3 = System.currentTimeMillis();
		System.out.println("ArrayList随机删除100个对象时间：" + (end3 - start3));
		// LinkedList随机删除100个:116
		long start4 = System.currentTimeMillis();
		for (int i = 0; i < 100; i++) {
			ll.remove(Math.random() * 100000);
		}
		long end4 = System.currentTimeMillis();
		System.out.println("LinkedList随机删除100个对象时间：" + (end4 - start4));

	}

}
